<?php

namespace app\index\model;

use think\Cache;
use think\Model;

class Config extends Model
{

    public static function getWebBasic()
    {
        $param = [
            'name' => '',
            'title' => '',
            'keywords' => '',
            'description' => '',
            'email' => '',
            'mobile' => '',
            'address' => '',
            'beian' => ''
        ];
        return self::getValue('web_basic', $param);
    }

    public static function getBaseValue($value)
    {
        $param = [
            'title' => '',
            'title_en' => '',
            'content' => ''
        ];
        return self::getValue($value, $param);
    }

    private static function getValue($name, $param)
    {
        $value = json_decode(Cache::get($name), true);
        if (!$value) {
            $value = json_decode(self::where('name', $name)->value('value'), true);
            if (!$value) {
                $value = $param;
            }
        }
        return $value;
    }





}
